using UnityEngine;

public class GameController
{
    private GameController()
    {
    }

    private static GameController instance = null;

    public static GameController Instance()
    {
        if (instance == null)
        {
#if UNITY_EDITOR
            Debug.Log("创建GameController实例.");
#endif
            instance = new GameController();
        }

        return instance;
    }

    private Game game;

    public Game GameHeart
    {
        set => game = value;
    }

    public ObjectController ObjectCtr { get; set; }
    
    public MapController mapCtr { get; set; }

    public PlayerController playerCtr { get; set; }

    public WeaponController weaponCtr { get; set; }
    
    public ArchiveController archiveCtr { get; set; }

    public FSMController FSM { get; set; }

    public PanelController panelCtr { get; set; }
    
    public PlayerDataController playerDataCtr { get; set; }
    
    public AudioController audioCtr { get; set; }
    
    public Transform gameUIRoot { get; set; }
    
    public GameObject gameCore { get; set; }
    
    public SmallMapBase smallMap { get; set; }
    
    public void Initialize()
    {
        playerCtr.Init();
        panelCtr.LoadPlayerPanel();
#if UNITY_ANDROID
        panelCtr.LoadPhonePanel();
#endif
    }

    public void Restart()
    {
        game.Restart();
    }
    
    public void Exit()
    {
        FSM.CurGameState = GameState.Login;
        game.ExitGame();
    }

    public Camera GetMainCamera()
    {
        return game.mainCamera;
    }

    public void CleanAllController()
    {
        mapCtr = null;
        playerCtr = null;
        archiveCtr = null;
        audioCtr = null;
        panelCtr = null;
        playerCtr = null;
        weaponCtr = null;
        playerDataCtr = null;
        smallMap = null;
    }
}